package com.zqweb.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.zqweb.common.valid.AddGroup;
import com.zqweb.common.valid.ListValue;
import com.zqweb.common.valid.UpdateForStatusGroup;
import com.zqweb.common.valid.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author zq
 * @email zq@gmail.com
 * @date 2021-11-26 18:38:54
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空！",groups = {AddGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotEmpty(message = "品牌logo不能为空！",groups = {AddGroup.class})
	@URL(message = "品牌logo的URL格式不对！",groups = {AddGroup.class,UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotEmpty(message = "status不能为空！",groups = {AddGroup.class})
	// 自定义1个校验注解，并使用自定义的校验器来设定校验规则。注意：同一个校验分组内使用的校验器需要保持一致，否则会报错
	@ListValue(val = {0,1},groups = {AddGroup.class,UpdateForStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母，Java中书写正则表达式，前后两个/  是不需要写的
	 */
	@NotNull(message = "检索首字母不能为空！",groups = {AddGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$",message = "请输入一个合法字母！",groups = {AddGroup.class,UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序字段内容不能为空！",groups = {AddGroup.class})// @NotEmpty不支持Integer类型
	@Min(value = 0,message = "排序值不能小于0！",groups = {AddGroup.class,UpdateGroup.class})
	private Integer sort;

}
